home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vbnets / vb_nets.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-06-12  |  13.4 KB  |  349 lines

  1. VERSION 2.00
  2. Begin Form frmVBNets 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "vb_Nets Sample"
  5.    ClientHeight    =   3450
  6.    ClientLeft      =   1335
  7.    ClientTop       =   1950
  8.    ClientWidth     =   6510
  9.    Height          =   4140
  10.    Icon            =   vb_NETS.FRX:0000
  11.    Left            =   1275
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3450
  14.    ScaleWidth      =   6510
  15.    Top             =   1320
  16.    Width           =   6630
  17.    Begin CommandButton cmdSel 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "&Find Drive"
  20.       Height          =   345
  21.       Index           =   3
  22.       Left            =   4830
  23.       TabIndex        =   14
  24.       Top             =   1590
  25.       Width           =   1515
  26.    End
  27.    Begin CommandButton cmdSel 
  28.       BackColor       =   &H00C0C0C0&
  29.       Caption         =   "Find &Service"
  30.       Height          =   345
  31.       Index           =   2
  32.       Left            =   4830
  33.       TabIndex        =   13
  34.       Top             =   1200
  35.       Width           =   1515
  36.    End
  37.    Begin CommandButton cmdSel 
  38.       BackColor       =   &H00C0C0C0&
  39.       Caption         =   "&Dismount"
  40.       Height          =   345
  41.       Index           =   1
  42.       Left            =   4830
  43.       TabIndex        =   12
  44.       Top             =   810
  45.       Width           =   1515
  46.    End
  47.    Begin CommandButton cmdSel 
  48.       BackColor       =   &H00C0C0C0&
  49.       Caption         =   "&Mount"
  50.       Height          =   345
  51.       Index           =   0
  52.       Left            =   4830
  53.       TabIndex        =   11
  54.       Top             =   420
  55.       Width           =   1515
  56.    End
  57.    Begin TextBox txtService 
  58.       Height          =   285
  59.       Index           =   3
  60.       Left            =   1380
  61.       TabIndex        =   6
  62.       Top             =   1410
  63.       Width           =   3045
  64.    End
  65.    Begin TextBox txtService 
  66.       Height          =   285
  67.       Index           =   2
  68.       Left            =   1380
  69.       TabIndex        =   5
  70.       Top             =   1080
  71.       Width           =   3045
  72.    End
  73.    Begin TextBox txtService 
  74.       Height          =   285
  75.       Index           =   1
  76.       Left            =   1380
  77.       TabIndex        =   4
  78.       Top             =   750
  79.       Width           =   3045
  80.    End
  81.    Begin TextBox txtService 
  82.       Height          =   285
  83.       Index           =   0
  84.       Left            =   1380
  85.       TabIndex        =   3
  86.       Top             =   420
  87.       Width           =   3045
  88.    End
  89.    Begin ListBox lstServices 
  90.       Height          =   1200
  91.       Left            =   150
  92.       TabIndex        =   0
  93.       TabStop         =   0   'False
  94.       Top             =   2160
  95.       Width           =   6195
  96.    End
  97.    Begin Label lblInstructions 
  98.       BackColor       =   &H00C0C0C0&
  99.       Caption         =   "Check 'Help' for instructions on using the service buttons ..."
  100.       Height          =   225
  101.       Left            =   540
  102.       TabIndex        =   2
  103.       Top             =   90
  104.       Width           =   5415
  105.    End
  106.    Begin Label lblService 
  107.       BackColor       =   &H00C0C0C0&
  108.       Caption         =   "Password:"
  109.       Height          =   195
  110.       Index           =   3
  111.       Left            =   180
  112.       TabIndex        =   10
  113.       Top             =   1470
  114.       Width           =   1095
  115.    End
  116.    Begin Label lblService 
  117.       BackColor       =   &H00C0C0C0&
  118.       Caption         =   "Service:"
  119.       Height          =   195
  120.       Index           =   2
  121.       Left            =   180
  122.       TabIndex        =   9
  123.       Top             =   1140
  124.       Width           =   1095
  125.    End
  126.    Begin Label lblService 
  127.       BackColor       =   &H00C0C0C0&
  128.       Caption         =   "Server:"
  129.       Height          =   195
  130.       Index           =   1
  131.       Left            =   180
  132.       TabIndex        =   8
  133.       Top             =   810
  134.       Width           =   1095
  135.    End
  136.    Begin Label lblService 
  137.       BackColor       =   &H00C0C0C0&
  138.       Caption         =   "Drive:"
  139.       Height          =   195
  140.       Index           =   0
  141.       Left            =   180
  142.       TabIndex        =   7
  143.       Top             =   480
  144.       Width           =   1095
  145.    End
  146.    Begin Label lblServiceList 
  147.       BackColor       =   &H00C0C0C0&
  148.       Caption         =   "Mounted Network Services:"
  149.       Height          =   225
  150.       Left            =   180
  151.       TabIndex        =   1
  152.       Top             =   1890
  153.       Width           =   2895
  154.    End
  155.    Begin Menu mnuFile 
  156.       Caption         =   "&File"
  157.       Begin Menu mnuFileSel 
  158.          Caption         =   "Network &User"
  159.          Index           =   0
  160.       End
  161.       Begin Menu mnuFileSel 
  162.          Caption         =   "Network &Type"
  163.          Index           =   1
  164.       End
  165.       Begin Menu mnuFileSel 
  166.          Caption         =   "-"
  167.          Index           =   2
  168.       End
  169.       Begin Menu mnuFileSel 
  170.          Caption         =   "E&xit"
  171.          Index           =   3
  172.       End
  173.    End
  174.    Begin Menu mnuHelp 
  175.       Caption         =   "&Help"
  176.       Begin Menu mnuHelpSel 
  177.          Caption         =   "Using 'Mount"""
  178.          Index           =   0
  179.       End
  180.       Begin Menu mnuHelpSel 
  181.          Caption         =   "Using 'Dismount'"
  182.          Index           =   1
  183.       End
  184.       Begin Menu mnuHelpSel 
  185.          Caption         =   "Using 'Find Service'"
  186.          Index           =   2
  187.       End
  188.       Begin Menu mnuHelpSel 
  189.          Caption         =   "Using 'Find Drive'"
  190.          Index           =   3
  191.       End
  192.       Begin Menu mnuHelpSel 
  193.          Caption         =   "-"
  194.          Index           =   4
  195.       End
  196.       Begin Menu mnuHelpSel 
  197.          Caption         =   "&About"
  198.          Index           =   5
  199.       End
  200.    End
  201. Option Explicit
  202. ' Copyright 
  203.  1994 by Computer Technologies, Inc. All rights reserved.
  204. Dim ftCRLF           As String
  205. Sub APP_ListServices ()
  206. ' Copyright 
  207.  1994 by Computer Technologies, Inc. All rights reserved.
  208.     Dim nLoopCtr            As Integer
  209.     Dim tTempStr            As String
  210. ' Hide the list box to avoid flashing
  211.     lstServices.Visible = False
  212. ' Clear the list box of all current entries
  213.     Do While lstServices.ListCount > 0
  214.         lstServices.RemoveItem 0
  215.     Loop
  216. ' Load the list box with all mounted services
  217.     For nLoopCtr = 4 To 26          ' For drives D: to Z:
  218.         tTempStr = UT_NetGetServiceName(Chr$(64 + nLoopCtr))
  219.         If Len(tTempStr) > 0 Then   ' The drive is mounted
  220.             lstServices.AddItem Chr$(64 + nLoopCtr) & ":" & Chr$(9) & tTempStr
  221.         End If
  222.     Next nLoopCtr
  223. ' Now that we are done we can show the list box
  224.     lstServices.Visible = True
  225. End Sub
  226. Sub cmdSel_Click (Index As Integer)
  227. ' Copyright 
  228.  1994 by Computer Technologies, Inc. All rights reserved.
  229.     Dim tTempStr            As String
  230.     Dim tService            As String
  231.     Dim nResult             As Integer
  232.     Dim nLoopCtr            As Integer
  233.     Select Case Index
  234.         Case 0              ' Mount
  235.             If Len((txtService(0))) = 0 Or Len((txtService(1))) = 0 Or Len((txtService(2))) = 0 Then
  236.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  237.                 Exit Sub
  238.             End If
  239.             tTempStr = UT_NetMount((txtService(0)), (txtService(1)), (txtService(2)), (txtService(3)))
  240.             If Len(tTempStr) <> 0 Then
  241.                 MsgBox "Service mounted", MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  242.                 Call APP_ListServices               ' Refresh the services list
  243.               Else
  244.                 tService = "\\" & (txtService(1)) & "\" & (txtService(2))
  245.                 MsgBox "Service NOT mounted", MB_ICONEXCLAMATION, "Service: " & tService
  246.             End If
  247.         
  248.         Case 1              ' Dismount
  249.             If Len((txtService(0))) = 0 Then
  250.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  251.                 Exit Sub
  252.             End If
  253.             nResult = UT_NetDismount((txtService(0)), NET_OPENQUERY)
  254.             If nResult = True Then
  255.                 MsgBox "Service dismounted", MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  256.                 Call APP_ListServices               ' Refresh the services list
  257.               Else
  258.                 MsgBox "Service NOT dismounted", MB_ICONEXCLAMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  259.             End If
  260.         
  261.         Case 2              ' Find Service
  262.             If Len((txtService(0))) = 0 Then
  263.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  264.                 Exit Sub
  265.             End If
  266.             tTempStr = UT_NetGetServiceName((txtService(0)))            ' Get the service name
  267.             If Len(tTempStr) <> 0 Then
  268.                 MsgBox "Service Name: " & tTempStr, MB_ICONINFORMATION, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  269.               Else
  270.                 MsgBox "There is no service connected to this drive.", MB_ICONSTOP, "Drive " & UCase$(Left$((txtService(0)), 1)) & ":"
  271.             End If
  272.         
  273.         Case 3              ' Find Drive
  274.             If Len((txtService(1))) = 0 Or Len((txtService(2))) = 0 Then
  275.                 Call mnuHelpSel_Click(Index)        ' Call help because there are missing parameters
  276.                 Exit Sub
  277.             End If
  278.             tService = "\\" & (txtService(1)) & "\" & (txtService(2))   ' Build the service name we are looking for
  279.             tTempStr = UT_NetGetServiceDrive(tService)                  ' Find the drive letter
  280.             If Len(tTempStr) <> 0 Then
  281.                 MsgBox "Service is connected to drive " & UCase$(tTempStr), MB_ICONINFORMATION, "Service: " & tService
  282.               Else
  283.                 MsgBox "This service is not mounted or connected to a local drive.", MB_ICONSTOP, "Service: " & tService
  284.             End If
  285.     End Select
  286. End Sub
  287. Sub Form_Load ()
  288. ' Copyright 
  289.  1994 by Computer Technologies, Inc. All rights reserved.
  290.     Dim tTempStr            As String
  291. ' Center the form on the screen
  292.     UT_CenterScreen Me
  293. ' Setup form scope globals
  294.     ftCRLF = Chr$(13) & Chr$(10)
  295. ' Load the services list box
  296.     Call APP_ListServices
  297. ' Popup the About box dialog
  298.     Call mnuHelpSel_Click(5)
  299. End Sub
  300. Sub mnuFileSel_Click (Index As Integer)
  301. ' Copyright 
  302.  1994 by Computer Technologies, Inc. All rights reserved.
  303.     Dim tTempStr            As String
  304.     Select Case Index
  305.         Case 0                  ' Network User
  306.             tTempStr = UT_NetUserID()
  307.             If Len(tTempStr) = 0 Then           ' Not logged in
  308.                 MsgBox "The user is not logged in to the network. It is also possible that this is a Windows for Workgroups machine using multiple network protocols. If Workgroups is not the first protocol, the user name may not be reported correctly.", MB_ICONINFORMATION, "Network User"
  309.               Else                              ' User is logged in
  310.                 MsgBox "Logged in to the network as: " & Trim$(tTempStr), MB_ICONINFORMATION, "Network User"
  311.             End If
  312.             
  313.         Case 1                  ' Network Type
  314.             tTempStr = UT_GetNetworkType()
  315.             If Len(tTempStr) = 0 Then           ' Unknown network type
  316.                 MsgBox "Unable to determine the network type for this system.", MB_ICONINFORMATION, "Network Type"
  317.               Else
  318.                 MsgBox "The current network is " & Trim$(tTempStr), MB_ICONINFORMATION, "Network Type"
  319.             End If
  320.         Case 3                  ' Exit
  321.             Unload frmVBNets
  322.             End
  323.     End Select
  324. End Sub
  325. Sub mnuHelpSel_Click (Index As Integer)
  326. ' Copyright 
  327.  1994 by Computer Technologies, Inc. All rights reserved.
  328.     Dim tTempStr            As String
  329.     Select Case Index
  330.         Case 0              ' Mount
  331.             MsgBox "The mount option requires a drive letter, a server name, and a service. The password is optional.", MB_ICONINFORMATION, "Using 'Mount'"
  332.         Case 1              ' Dismount
  333.             MsgBox "The dismount option requires a drive letter.", MB_ICONINFORMATION, "Using 'Dismount'"
  334.         Case 2              ' Find Service
  335.             MsgBox "The find service option requires a drive letter.", MB_ICONINFORMATION, "Using 'Find Service'"
  336.         Case 3              ' Find Drive
  337.             MsgBox "The find drive option requires a server name and a service.", MB_ICONINFORMATION, "Using 'Find Drive'"
  338.         Case 5              ' About
  339.             tTempStr = "Copyright 
  340.  1994 by Computer Technologies, Inc." & ftCRLF & "All rights reserved."
  341.             tTempStr = tTempStr & ftCRLF & ftCRLF & "Version 1.1 - Released October 11, 1994."
  342.             tTempStr = tTempStr & ftCRLF & ftCRLF & "This demo program and the associated code in cti_NETS.BAS are the property of Computer Technologies, Inc. It is provided as a service for the personal use of the members of the MS-BASIC forum on CompuServe, and other interested Visual Basic developers."
  343.             tTempStr = tTempStr & ftCRLF & ftCRLF & "Author:" & Chr$(9) & "Eric Brierley"
  344.             tTempStr = tTempStr & ftCRLF & "CIS:" & Chr$(9) & "71163,2657"
  345.             tTempStr = tTempStr & ftCRLF & "Phone:" & Chr$(9) & "1-704-634-1766"
  346.             MsgBox tTempStr, MB_ICONINFORMATION, "About vb_NETS"
  347.     End Select
  348. End Sub
  349.